//
//  NoDataView.m
//  AntsExpress
//
//  Created by slccper on 16/1/1.
//  Copyright © 2016年 slccper. All rights reserved.
//
#import "NoDataView.h"

@interface NoDataView()

@property(strong,nonatomic) UILabel * messageLB;

@end

@implementation NoDataView

@synthesize message;

-(id) initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if(self){
        self.backgroundColor=[UIColor clearColor];
        self.messageLB=[[UILabel alloc] init];
        self.messageLB.backgroundColor=[UIColor clearColor];
        self.messageLB.textColor=[UIColor brownColor];
        self.messageLB.textAlignment=NSTextAlignmentCenter;
        self.messageLB.numberOfLines=0;
        self.messageLB.font=[UIFont systemFontOfSize:16];
        [self addSubview:self.messageLB];
    }
    return self;
}

-(void)setMessage:(NSString *)pmessage{
    message=pmessage;
    CGRect rect=[message boundingRectWithSize:CGSizeMake(self.frame.size.width-20, INT_MAX) options:(NSStringDrawingUsesLineFragmentOrigin |NSStringDrawingUsesFontLeading) attributes:@{NSFontAttributeName:self.messageLB.font} context:nil];
    self.messageLB.text=message;
    self.messageLB.frame=CGRectMake(10, (self.frame.size.height-rect.size.height)/2, self.frame.size.width-20, rect.size.height);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
